package com.ruoyi.web.controller.light;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.domain.light.LitErr;
import com.ruoyi.common.domain.light.view.LitErrView;
import com.ruoyi.dict.service.IDictDeviceService;
import com.ruoyi.light.service.ILitErrService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/light")
@RequiredArgsConstructor(onConstructor_ = {@Autowired})
public class litLightController extends BaseController {

    private final IDictDeviceService dictDeviceService;
    private final ILitErrService litErrService;

    /**
     * 查询安灯配置 - 异常类型列表
     */
    @RequestMapping("/lit/list")
    public AjaxResult list(String deviceGroupName, String deviceName, String litStatus) {
        return AjaxResult.success(dictDeviceService.getDictDeviceVoList(deviceGroupName, deviceName, litStatus));
    }

    /**
     * 安灯异常记录
     */
    @RequestMapping("litErr/list")
    public AjaxResult litErrList(@RequestParam Long deviceId, String status) {
        return AjaxResult.success(litErrService.getLitErrViewMyErrPage(deviceId, status));
    }

    /**
     * 安灯异常记录
     */
    @RequestMapping("litErr/page")
    public TableDataInfo litErrPage(LitErrView litErr) {
        Page<LitErrView> page = getPage();
        return getDataTable(litErrService.getLitErrViewPage(page, litErr));
    }

    /**
     * 安灯异常记录
     */
    @RequestMapping("litErr/page/myErr")
    public TableDataInfo litErrList(LitErrView litErr) {
        Page<LitErrView> page = getPage();
        return getDataTable(litErrService.getLitErrViewMyErrPage(page, litErr));
    }


    /**
     * 安灯操作  红灯不可发起安灯
     */
    @RequestMapping("oper/{operType}")
    public AjaxResult oper(@PathVariable(value = "operType") String operType, @RequestBody LitErr litErr) {
        return litErrService.oper(litErr, operType);
    }



}
